<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>v-if v-show demo</title>
        <script src="../../lib/vue-dev/dist/vue.min.js"></script>
    </head>

    <body>
        <div id="app">
            <!-- <input type="button" value="toggle" @click="toggle" /> -->
            <input type="button" value="toggle" @click="flag = !flag" />
            <!-- v-if特点：每次都会重新删除或创建元素 -->
            <!-- v-show特点：每次不会重新进行dom的删除和创建操作，只是切换了元素的display：none样式 -->
            <h3 v-if="flag">这是v-if控制元素</h3>
            <h3 v-show="flag">这是v-show控制元素</h3>
        </div>

        <script>
            var vm = new Vue({
                el: '#app',
                data: {
                    flag: true
                },
                methods: {
                    toggle() {
                        this.flag = !this.flag;
                    }
                }
            });
        </script>
    </body>

</html>